package com.common.http;

import org.springframework.validation.BindingResult;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;

public class HttpResult {

	private int code = HttpStatus.SUCCESS_CODE;
	private String msg = HttpStatus.SUCCESS_MESSAGE;
	private Object data;
	private Object biz;
	private int total;
	private Object rows;
	private Object footer;

	public static HttpResult error() {
		return error(HttpStatus.GLOBAL_EXCEPTION_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
	}

	public static HttpResult error(String msg) {
		return error(HttpStatus.GLOBAL_EXCEPTION_CODE, msg);
	}

	public static HttpResult error(int code, String msg) {
		HttpResult r = new HttpResult();
		r.setCode(code);
		r.setMsg(msg);
		return r;
	}

	public static HttpResult error(int code, String msg, Object data) {
		HttpResult r = new HttpResult();
		r.setCode(code);
		r.setMsg(msg);
		r.setData(data);
		return r;
	}

	public static HttpResult ok(String msg) {
		HttpResult r = new HttpResult();
		r.setMsg(msg);
		return r;
	}

	public static HttpResult ok(Object data) {
		HttpResult r = new HttpResult();
		r.setData(data);
		return r;
	}

	public static HttpResult ok(String msg, Object data) {
		HttpResult r = new HttpResult();
		r.setMsg(msg);
		r.setData(data);
		return r;
	}

	public static HttpResult ok() {
		return new HttpResult();
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Object getBiz() {
		return biz;
	}

	public void setBiz(Object biz) {
		this.biz = biz;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public Object getRows() {
		return rows;
	}

	public void setRows(Object rows) {
		this.rows = rows;
	}

	public Object getFooter() {
		return footer;
	}

	public void setFooter(Object footer) {
		this.footer = footer;
	}

}
